package com.powernode.factory;

import com.powernode.strategy.LoginStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 生产登录策略的工厂
 * @Author: Tong Ziyu
 * @Date: 2024/10/26 11:54
 */

@Component
public class LoginStrategyFactory {

    /**
     * 里面存放不同的登录策略,key就是@Service()的value值
     */
    @Autowired
    private Map<String, LoginStrategy> loginStrategyMap = new HashMap<>();

    /**
     * 根据用户的登录类型，获取对应的登录策略
     * @param loginType
     * @return
     */
    public LoginStrategy getInstance(String loginType){
        return loginStrategyMap.get(loginType);
    }

}
